<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<%@ include file="/WEB-INF/views/include/easyui.jsp"%>
</head>
<body style="font-family: '微软雅黑'">
	<div id="tb" style="padding: 5px; height: auto">
		<div>
			<form id="searchFrom" action="">
				<input type="text" name="filter_LIKES_os"
					class="easyui-validatebox" data-options="width:150,prompt: '操作系统'" />
				<select id="cc" class="easyui-combobox" name="filter_LIKES_appname"
					data-options="width:150,panelHeight:100,prompt: 'App名称'" >
					<option></option>
					<option value="0">B端</option>
					<option value="1">C端</option>
				</select> <span class="toolbar-item dialog-tool-separator"></span> <a
					href="javascript(0)" class="easyui-linkbutton" plain="true"
					iconCls="icon-search" onclick="cx()">查询</a>
			</form>
			<!--  -->
			<shiro:hasPermission name="lcs:versionInfo:add">
				<a href="#" class="easyui-linkbutton" plain="true"
					iconCls="icon-add" onclick="add();">添加</a>
				<span class="toolbar-item dialog-tool-separator"></span>
			</shiro:hasPermission>
			<shiro:hasPermission name="lcs:versionInfo:delete">
				<a href="#" class="easyui-linkbutton" plain="true"
					iconCls="icon-remove" onclick="del()">删除</a>
				<span class="toolbar-item dialog-tool-separator"></span>
			</shiro:hasPermission>
			<shiro:hasPermission name="lcs:versionInfo:update">
				<a href="#" class="easyui-linkbutton" plain="true"
					iconCls="icon-edit" onclick="upd()">修改</a>
				<span class="toolbar-item dialog-tool-separator"></span>
			</shiro:hasPermission>
		</div>
	</div>
	<table id="dg"></table>

	<div id="dlg"></div>
	<div id="icon_dlg"></div>
	<div id="editor_dlg"></div>
	<script type="text/javascript">
		var dg;
		var d;
		var permissionDg;
		var parentPermId;
		$(function() {
			dg = $('#dg')
					.datagrid(
							{
								method : "get",
								url : '${ctx}/verinfo/getAll',
								queryParams:{
						    		sort: 'recordtime', 
						    		order: 'desc'
						    		},
								fit : true,
								fitColumns : true,
								border : false,
								idField : 'id',
								striped : true,
								pagination : true,
								rownumbers : true,
								pageNumber : 1,
								pageSize : 20,
								pageList : [ 10, 20, 30, 40, 50 ],
								singleSelect : true,
								columns : [ [
										{
											field : 'id',
											title : 'id',
											hidden : true,
											width : 100
										},
										{
											field : 'os',
											title : '操作系统',
											align : 'center',
											width : 40
										},
										{
											field : 'appname',
											title : 'App名称',
											align : 'center',
											formatter : function(value,
													rowData, rowIndex) {
												if (value == '1') {
													return "<span style='color: green;'>C端</span>";
												} else if(value == '0') {
													return "<span style='color: green;'>B端</span>";
												}else{
													return "<span style='color: red;'>未知</span>";
												}
											},
											width : 40
										},
										{
											field : 'appType',
											title : 'App类型',
											align : 'center',
											formatter : function(value,
													rowData, rowIndex) {
												if(rowData.os == 'iOS') {
													if (value == '0') {
														return "线下扫码版";
													} else {
														return "AppStore版";
													}
												} else {
													return '线下扫码版'
												}
											},
											width : 40
										},
										{
											field : 'version',
											title : '版本号',
											align : 'center',
											width : 40
										},
										{
											field : 'appurl',
											title : '下载地址',
											width : 160,
											hidden : false
										},
										{
											field : 'updatestatus',
											title : '更新类型',
											width : 40,
											align : 'center',
											sortable : false,
											formatter : function(value,
													rowData, rowIndex) {
												if (value == '1') {
													return "<span style='color: red;'>强制更新</span>";
												} else if(value == '0') {
													return "<span style='color: green;'>不强制更新</span>";
												}else{
													return "<span style='color: red;'>未知</span>";
												}
											}
										},
										{
											field : 'recordtime',
											title : '创建时间',
											align : 'center',
											formatter : function(value, row,
													index) {
												return formatTime(value);
											},
											width : 60
										} ] ],
								enableHeaderClickMenu : false,
								enableHeaderContextMenu : false,
								enableRowContextMenu : false,
								toolbar : '#tb'
							});

		});

		//弹窗增加
		function add() {

			d = $('#dlg').dialog({
				title : '添加版本',
				width : 350,
				height : 300,
				closed : false,
				cache : false,
				maximizable : true,
				resizable : true,
				href : '${ctx}/verinfo/create',
				modal : true,
				buttons : [ {
					text : '确认',
					handler : function() {
						$("#mainform").submit();
						dg.datagrid('reload');
					}
				}, {
					text : '取消',
					handler : function() {
						d.panel('close');
					}
				} ]
			});
		}

		//删除
		function del() {
			var row = dg.datagrid('getSelected');
			if (rowIsNull(row))
				return;
			parent.$.messager.confirm('提示', '删除后无法恢复您确定要删除？', function(data) {
			if (data) {
				$.ajax({
					type : 'get',
					url : "${ctx}/verinfo/delete/" + row.id,
					success : function(data) {
						if (successTip(data, dg))
							dg.datagrid('reload');
					}
				});
					//dg.datagrid('reload'); //grid移除一行,不需要再刷新
			}
			});

		}
		
		//修改
		function upd() {
			var row = dg.datagrid('getSelected');
			if (rowIsNull(row))
				return;
			d = $("#dlg").dialog({
				title : '修改版本',
				width : 350,
				height : 300,
				href : '${ctx}/verinfo/update/' + row.id,
				maximizable : true,
				modal : true,
				buttons : [ {
					text : '确认',
					handler : function() {
						$("#mainform").submit();
					}
				}, {
					text : '取消',
					handler : function() {
						d.panel('close');
					}
				} ]
			});

		}
		
		//创建查询对象并查询
		function cx() {
			var obj = $("#searchFrom").serializeObject();
			obj.filter_LIKES_os = encodeURIComponent(obj.filter_LIKES_os);
			dg.datagrid('reload', obj);
		}
		var nowIcon;
		var icon_dlg;
	</script>
</body>

</html>